﻿SELECT B.CIF, B.CUS_NAME, C.BRANCH_NAME_SME, C.REGION, B.BRANCH_ID, b.CUS_OPEN_DATE, B.DAO, B.DAO_NAME, B.INDUSTRY_NAME, B.INDUSTRY_NAME_EN, A.HAN_MUC_THE_TOI_DA_DUOC_CAP, A.THOI_HAN_TOI_DA_CUA_THE
INTO TBL_XSELLING_PRE_APPROVED_CREDIT_CARD
FROM PRE_APPROVED_CREDIT_CARD_201610 A, TBL_CUSTOMER B, TBL_BRANCH C
WHERE A.CIF=B.CIF AND B.BRANCH_ID = C.BRANCH_ID

--drop table TBL_XSELLING_PRE_APPROVED_CREDIT_CARD

SELECT * FROM TBL_XSELLING_PRE_APPROVED_CREDIT_CARD

SELECT B.CIF, B.CUS_NAME, C.BRANCH_NAME_SME, C.REGION, B.BRANCH_ID, b.CUS_OPEN_DATE, B.DAO, B.DAO_NAME, B.INDUSTRY_NAME, B.INDUSTRY_NAME_EN, A.sum_limit, A.time_remain, a.limit_bill_duoc_cap, a.date_approve, a.[Đa GN TOP UP BIL], a.[Đã GN BIL thường]
--INTO TBL_XSELLING_PRE_BIL_NEW
FROM PRE_APPROVED_BIL_NEW_201610 A, TBL_CUSTOMER B, TBL_BRANCH C
WHERE A.CIF=B.CIF AND B.BRANCH_ID = C.BRANCH_ID

select * from TBL_XSELLING_PRE_BIL_NEW

delete from server12.SMECustomer360.[dbo].TBL_XSELLING_PRE_APPROVED_CREDIT_CARD
insert server12.SMECustomer360.dbo.TBL_XSELLING_PRE_APPROVED_CREDIT_CARD
select * from TBL_XSELLING_PRE_APPROVED_CREDIT_CARD

delete from server12.SMECustomer360.[dbo].TBL_XSELLING_PRE_BIL_NEW
insert server12.SMECustomer360.dbo.TBL_XSELLING_PRE_BIL_NEW
select * from TBL_XSELLING_PRE_BIL_NEW

delete from TBL_XSELLING_PRE_WC

insert TBL_XSELLING_PRE_WC
select B.CIF, B.CUS_NAME, C.BRANCH_NAME_SME, C.REGION, B.BRANCH_ID, b.CUS_OPEN_DATE, B.DAO, B.DAO_NAME, B.INDUSTRY_NAME, B.INDUSTRY_NAME_EN, A.THOI_GIAN_CON_LAI_HANMUC, A.TONG_GIATRI_HANMUC, a.APPROVAL_DATE, a.EXPIRY_DATE
from gianglh3.taicapnhanh.dbo.DS_KH_TAICAP_201701 a, TBL_CUSTOMER B, TBL_BRANCH C
where A.CIF=B.CIF 
AND B.BRANCH_ID = C.BRANCH_ID 
and a.CHECK_EWS_TOP_DOWN = 'YES'
and a.CHECK_EWS_BOTTOM_UP = 'YES'
and a.CHECK_WATCH_LIST = 'YES'
and a.CHECK_COCAUNO = 'YES'
and a.CHECK_DS_AMC = 'YES'
and a.CHECK_DS_DEN = 'YES'
and a.CHECK_DS_NGHINGO = 'YES'
and a.CHECK_NGUNG_HD = 'YES'
and a.CHECK_GIA_TRI_HANMUC = 'YES'
and a.CHECK_TS_DAMBAO = 'YES'
and a.CHECK_THOIGIANG_CONLAI_HANMUC = 'YES'
and a.CHECK_PHANLUONG = 'YES'

select * from TBL_XSELLING_PRE_WC



delete from server12.SMECustomer360.[dbo].[TBL_XSELLING_RATE_USING_LIMIT]
insert server12.SMECustomer360.dbo.[TBL_XSELLING_RATE_USING_LIMIT]
select * from [TBL_XSELLING_RATE_USING_LIMIT]



delete from server12.SMECustomer360.[dbo].[TBL_XSELLING_PRE_WC]
insert server12.SMECustomer360.dbo.[TBL_XSELLING_PRE_WC]
select * from [TBL_XSELLING_PRE_WC]